function load() {
    // if (localStorage.getItem("phone")!=null){
    //         document.getElementById("account").setAttribute("value",localStorage.getItem("phone"));
    //         document.getElementById("password").setAttribute("value",localStorage.getItem("pwd"));
    //     }

    // if (localStorage.getItem("phone")!=null){
    // layer.confirm('是否自动登录？', {
    //     btn: ['确定','取消'] //按钮
    // }, function(){
    //         document.getElementById("account").setAttribute("value",localStorage.getItem("phone"));
    //         document.getElementById("password").setAttribute("value",localStorage.getItem("pwd"));
    //         message();
    //     }, function(){
    //     document.getElementById("account").setAttribute("value","");
    //     document.getElementById("password").setAttribute("value","");
    // });
    // }
}


function message() {

    var phone = document.getElementById("account").value;
    var pass1 = document.getElementById("password").value;
    var code = document.getElementById("code").value;
    var pass2 = $.md5(pass1).toUpperCase();

    if (!(/^[1][3,4,5,6,7,8,9][0-9]{9}$/.test(phone))) {
        layer.msg("请输入正确的手机号！", {
            icon: 2,
            time: 1000,
            offset: 80,
            end: function () {
            }
        });
    } else if ((pass1.length < 8) || !(/[A-Za-z].*[0-9]|[0-9].*[A-Za-z]/.test(pass1))) {
        layer.msg("密码不合法，请检查!", {
            icon: 2,
            time: 1000,
            offset: 80,
            end: function () {
            }
        });
    } else {
        var data = {
            Authorization:"Bearer eyJhbGciOiJIUzI1NiJ9.eyJqdGkiOiIxODg4ODg4ODg4OCIsImlhdCI6MTYwNzk1Njg1Mywicm9sZSI6ImFkbWluIiwicGVybXMiOiJzdXBlciIsImV4cCI6MTYyMzUwODg1M30.O7v3Yu9A8Q33UGV6POJ-iE1HPBxPlBSfwqD13E65Nzc",
            userPhone: phone,
            password: pass2,
            code: code
        }
        $.ajax({
            type: "POST",//方法
            url: "http://Localhost:8282/user/login",//表单接收url
            contentType:"application/json",
            data:  JSON.stringify(data),
            success: function (response) {
                if (response.status == 200) {
                    layer.msg("登录成功!", {
                        icon: 1,
                        time: 500,
                        end: function () {
                            var index = parent.layer.getFrameIndex(window.name);
                            parent.layer.close(index);
                            location.reload();//do something
                            // var tempwindow = window.open();
                            // window.location = "http://Localhost:8282/3180421050/showGarbage.html";
                            // window.onclose;
                            location.href = "http://Localhost:8282/3180421050/showGarbage.html";
                        }
                    });
                } else {
                    layer.msg(response.msg, {
                        icon: 2,
                        time: 1000,
                        offset: 80,
                        end: function () {
                        }
                    });
                }
            }
        });

        // if(document.getElementById("remember").getAttribute("checked") == "true"){
        //     localStorage.setItem("phone",phone);
        //     localStorage.setItem("pwd",pass1);
        // }
        //


    }
    // else{
    //     layer.msg("账号密码错误!", {
    //         icon: 2,
    //         time: 1000,
    //         end: function () {
    //             var index = parent.layer.getFrameIndex(window.name);
    //             parent.layer.close(index);
    //             location.reload();//do something
    //         }
    //     });
    // }
}

function pwd1() {
    document.getElementById("account").setAttribute("placeholder", "");
}

function pwd() {
    document.getElementById("password").setAttribute("placeholder", "");
}

function pwd2() {
    document.getElementById("code").setAttribute("placeholder", "");
}

function set1() {
    document.getElementById("account").setAttribute("placeholder", "  请输入手机号码");
}

function set() {
    document.getElementById("password").setAttribute("placeholder", "  请输入密码");
}

function set2() {
    document.getElementById("code").setAttribute("placeholder", "  请输入正确的验证码");
}

function reloadCode() {
    //time变量的功能是强制刷新，忽略浏览器的缓存机制
    console.log("test");
    var time = new Date().getTime();
    document.getElementById("imageCode").src = "http://Localhost:8282/user/kaptcha?"+time;//通过time强制刷新
}
